import pymysql
#数据库中插入数据
def insert_novel_mysql(url,Public_platform,Novel_name,Chapter,datetime,Extension_name):
    conn = pymysql.Connect(
        host='',  ##mysql服务器地址
        port=3306,  ##mysql服务器端口号
        user='root',  ##用户名
        password='nx123',  ##密码
        db='nx_extension_link_novel',  ##数据库名
        charset='utf8'  ##连接编码
    )
    cursor = conn.cursor()
    sql_insert = "INSERT INTO extension_link_novel_mysql(url,insertTime,Public_platform,Novel_name,Chapter,datetime,Extension_name) values('{0}',now(),'{1}','{2}','{3}','{4}','{5}')".format(url,Public_platform,Novel_name,Chapter,datetime,Extension_name)
    # 执行语句
    cursor.execute(sql_insert)
    #事务提交，否则数据库得不到更新
    conn.commit()
    cursor.close()
    conn.close()